
package com.zhu.salesmanagement.network;

import java.text.Format;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.ContentValues;
import android.content.Context;
import android.util.Log;

import com.zhu.salesmanagement.MainActivity;
import com.zhu.salesmanagement.common.Actions;
import com.zhu.salesmanagement.models.CustomerItem;
import com.zhu.salesmanagement.models.CustomerShelfsItem;
import com.zhu.salesmanagement.models.ProductCategoryItem;
import com.zhu.salesmanagement.models.RemindMsgItem;
import com.zhu.salesmanagement.models.SyncProductItem;
import com.zhu.salesmanagement.models.SyncTaskItem;
import com.zhu.salesmanagement.models.VerifyUserResult;
import com.zhu.salesmanagement.provider.SalesSettings;
import com.zhu.salesmanagement.utils.Util;

public class ParseData {

	public static final int UPDATE = 1;
	public static final int DELETE = 0;

    public static String data = "";

    /**
     * 解析登录结果数据
     * @param result 登录结果数据
     */
    public static VerifyUserResult parseLogin(Object result) {
        if (result != null) {
            data = "" + result;
            VerifyUserResult resule = new VerifyUserResult();
            Map<String, Object> map = (Map<String, Object>) result;
            resule.mUUID = (String) map.get("UUID");
            resule.status = 1;
            resule.id = (String) map.get("sEmployeeID");
            resule.name = (String) map.get("sSalesPerson");
            resule.startLat = (String) map.get("decStartSiteLatitude");
            resule.startLng = (String) map.get("decStartSiteLongitude");
            resule.endLat = (String) map.get("decEndSiteLatitude");
            resule.endLng = (String) map.get("decEndSiteLongitude");
            resule.isNeedUpdate = (Integer) map.get("ifupdate") == 1 ? true : false;
            resule.mDecVersion = (String) map.get("decVersion");
            resule.sDownPath = (String) map.get("sDownPath");
            resule.sFileSize = (long)(Integer) map.get("iFileSize");
            resule.iGPSInterval = (Integer) map.get("iGPSInterval");
            resule.isOffline = false;
            if(Actions.DEBUG){
            	Log.e("zhu", "" + (Integer) map.get("ifupdate"));
            	Log.e("zhu",(String) map.get("decVersion"));
            	Log.e("zhu",(String) map.get("sDownPath"));
            	Log.e("zhu", "" + (Integer) map.get("iFileSize"));
            	Log.e("zhu", "" + (Integer) map.get("iGPSInterval"));
            }
            return resule;
        }
        result = null;
        return null;
    }

    /**
     * 解析门店结果数据
     * @param result 门店结果数据
     * @param context 上下文
     */
    public static ArrayList<CustomerItem> parseCustomer(Object result, Context context) {
        if (Actions.DEBUG) {
            Log.e("zhu", "---------------------------parseCustomer=" + result);
        }
        ArrayList<CustomerItem> clist = null;
        boolean isSuccess = false;
        if (result != null) {
            try {
            	clist = new ArrayList<CustomerItem>();
            	Map<String, Object> map = (Map<String, Object>) result;
            	Object[] list = (Object[])map.get("updateCustomers"); 
                if (Actions.DEBUG) {
                    Log.e("zhu", "length=" + list.length);
                }
                for (int i = 0; i < list.length; i++) {
                    Map<String, Object> map2 = (Map<String, Object>) list[i];
                    CustomerItem item = new CustomerItem();
                    item.sCustomerID = (String)map2.get("sCustomerID");
                    if (Actions.DEBUG) {
                        Log.e("zhu", "sCustomerID=" + item.sCustomerID);
                    }
                    item.sCustomerName = (String) map2.get("sCustomerName");
                    item.sCustomerAddress = (String) map2.get("sCustomerAddress");
                    item.sCustomerContractor = (String) map2.get("sCustomerContractor");
                    item.sTel = (String) map2.get("sTel");
                    item.sDealtEmployeeID = (String) map2.get("sDealtEmployeeID");
                    item.iVisitCategory = (String) map2.get("iVisitCategory");
                    item.sStoreLevel = (String) map2.get("sStoreLevel");
                    item.sStoreCategory = (String) map2.get("sStoreCategory");
                    item.sLatitude = (String) map2.get("decLatitude");
                    item.sLongitude = (String) map2.get("decLongitude");
                    item.iProperty = (Integer) map2.get("iStorePropertyInquire");
                    item.mType = UPDATE;
                    clist.add(item);
//                    ContentValues values = new ContentValues();
//                    // Log.e("zhu","cusid="+(String)map.get("sCustomerID"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_ID,
//                            (String) map2.get("sCustomerID"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_NAME,
//                            (String) map2.get("sCustomerName"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_ADDRESS,
//                            (String) map2.get("sCustomerAddress"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_CONTACT,
//                            (String) map2.get("sCustomerContractor"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_TEL,
//                            (String) map2.get("sTel"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_DEALTID,
//                            (String) map2.get("sDealtEmployeeID"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_VISITCODE,
//                            (String) map2.get("iVisitCategory"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_LEVEL,
//                            (String) map2.get("sStoreLevel"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_TYPE,
//                            (String) map2.get("sStoreCategory"));
////                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_STATUS,
////                            (String) map2.get("iStatus"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_LAT,
//                            (String) map2.get("decLatitude"));
//                    values.put(SalesSettings.CustomerSColumns.CUSTOMER_LNG,
//                            (String) map2.get("decLongitude"));
//
//                    context.getContentResolver().insert(SalesSettings.CustomerSColumns.CONTENT_URI,
//                            values);
                }

                Object[] deleteList = (Object[])map.get("deleteCustomers"); 
                if (Actions.DEBUG) {
                    Log.e("zhu", "delete length=" + deleteList.length);
                }
                for (int i = 0; i < deleteList.length; i++) {
                    String pcid = (String) deleteList[i];
                    CustomerItem item = new CustomerItem();
                    item.sCustomerID = pcid;
                    item.mType = DELETE;
                    clist.add(item);
                    if (Actions.DEBUG) {
                    	Log.e("zhu", "delete pcid=" + pcid);
                    }
                }
                isSuccess = true;
            } catch (Exception e) {
                if (Actions.DEBUG) {
                    e.printStackTrace();
                }
                isSuccess = false;
                clist = null;
            }
        }
        result = null;
        return clist;
    }

    /**
     * 解析产品大类结果数据
     * @param result 产品大类结果数据
     * @param context 上下文
     */
    public static ArrayList<ProductCategoryItem> parseProductCategory(Object result, Context context) {
        if (Actions.DEBUG) {
            Log.e("zhu", "----------------------------------parseProductCategory=" + result);
        }
        ArrayList<ProductCategoryItem> pList = null;
        boolean isSuccess = false;
        if (result != null) {
            try {
            	pList = new ArrayList<ProductCategoryItem>();
            	Map<String, Object> map = (Map<String, Object>) result;
            	Object[] list = (Object[])map.get("updateProductCategorys"); 
            	if (Actions.DEBUG) {
                    Log.e("zhu", "updates length=" + list.length);
                }
                for (int i = 0; i < list.length; i++) {
                    Map<String, Object> map2 = (Map<String, Object>) list[i];
                    ProductCategoryItem item = new ProductCategoryItem();
                    item.mProductCategoryId = (String) map2.get("sProductCategoryID");
                    item.mProductCategoryName = (String) map2.get("sProductCategory");
                    item.mType = UPDATE;
                    pList.add(item);
                    //ContentValues values = new ContentValues();
                    //values.put(SalesSettings.ProductCategoryColumns.PRODUCTCATEGORY_ID, (String) map2.get("sProductCategoryID"));
                    //values.put(SalesSettings.ProductCategoryColumns.PRODUCTCATEGORY_NAME, (String) map2.get("sProductCategory"));
                    //context.getContentResolver().insert(SalesSettings.ProductCategoryColumns.CONTENT_URI_NO_NOTIFICATION, values);
                    if(Actions.DEBUG){
                        Log.e("zhu", "===============parseProductCategory");
                        Log.e("zhu", "sProductCategoryID=" + (String) map2.get("sProductCategoryID"));
                        Log.e("zhu", "sProductCategory=" + (String) map2.get("sProductCategory"));
                    }
                }

                Object[] deleteList = (Object[])map.get("deleteProductCategorys"); 
                if (Actions.DEBUG) {
                    Log.e("zhu", "delete length=" + deleteList.length);
                }
                for (int i = 0; i < deleteList.length; i++) {
                    String pcid = (String) deleteList[i];
                    ProductCategoryItem item = new ProductCategoryItem();
                    item.mProductCategoryId = pcid;
                    item.mType = DELETE;
                    pList.add(item);
                    if (Actions.DEBUG) {
                    	Log.e("zhu", "delete pcid=" + pcid);
                    }
                }

                Date fromat = (Date) map.get("syncStartTime");
                Util.mVerifyUserResult.mStartSyncTime = fromat.getTime();
                if (Actions.DEBUG) {
                	Log.e("zhu","format="+fromat.toString() + "," + Util.mVerifyUserResult.mStartSyncTime);
                }

                isSuccess = true;
            } catch (Exception e) {
                if (Actions.DEBUG) {
                    e.printStackTrace();
                }
                pList = null;
            }
        }else{
        	pList = null;
        }
        result = null;
        return pList;
    }

    /**
     * 解析提醒结果数据
     * @param result 提醒结果数据
     * @param context 上下文
     */
    public static ArrayList<RemindMsgItem> parseRemindMsg(Object result, Context context) {
        if (Actions.DEBUG) {
            Log.e("zhu", "---------------------------------parseRemindMsg=" + result);
        }
        ArrayList<RemindMsgItem> rlist = null;
        if (result != null) {
            try {
            	rlist = new ArrayList<RemindMsgItem>();
                Object[] list = (Object[]) result;
                if (Actions.DEBUG) {
                    Log.e("zhu", "length=" + list.length);
                }
                for (int i = 0; i < list.length; i++) {
                    Map<String, Object> map = (Map<String, Object>) list[i];
                    RemindMsgItem item = new RemindMsgItem();
                    item.sEmployeeID = (String) map.get("sEmployeeID");
                    item.iRemindMSGID = (String) map.get("iRemindMSGID");
                    item.sRemindMSGText = (String) map.get("sRemindMSGText");
                    Date date = (Date) map.get("dRemindTime");
                    item.dRemindTime = String.valueOf(date.getTime());
                    item.iCycleCategory = (String) map.get("iCycleCategory");
                    item.sCustomerID = (String) map.get("sCustomerID");
                    Date date2 = (Date) map.get("dRemindDeadline");
                    item.dDeadTime = String.valueOf(date2.getTime());
                    rlist.add(item);
                    if(Actions.DEBUG){
                    	Log.e("zhu", "===================parseRemindMsg=");
                    	Log.e("zhu", "sEmployeeID="+item.sEmployeeID);
                    	Log.e("zhu", "sRemindMSGText="+item.sRemindMSGText);
                    	Log.e("zhu", "dRemindTime="+ date.toString());
                    	Log.e("zhu", "iCycleCategory="+ item.iCycleCategory);
                    }
//                    map.put("sEmployeeID", "xxx");
//                    map.put("iRemindMSGID", "xxx");
//                    map.put("sRemindMSGText", "测试消息阿打发哈桑觉得发哈地方哈桑戴假发回到附件啊哈地方阿计算多行发街上地方");
//                    map.put("iCycleCategory", 2);
//                    map.put("sCustomerID", "0");
//                    map.put("iStatus", "0");
//                    ContentValues values = new ContentValues();
//                    values.put(SalesSettings.RemindsColumns.EMPLOYEEID,
//                            (String) map.get("sEmployeeID"));
//                    values.put(SalesSettings.RemindsColumns.MESSAGEID,
//                            (String) map.get("iRemindMSGID"));
//                    values.put(SalesSettings.RemindsColumns.TEXT,
//                            (String) map.get("sRemindMSGText"));
//                    //Format fromat = (Format) map.get("dRemindTime");
//                    //values.put(SalesSettings.RemindsColumns.TIME, fromat.toString());
//                    values.put(SalesSettings.RemindsColumns.TYPE,
//                            String.valueOf((Integer) map.get("iCycleCategory")));
//                    values.put(SalesSettings.RemindsColumns.CUSTOMERID,
//                            (String) map.get("sCustomerID"));
//                    values.put(SalesSettings.RemindsColumns.STATUS, (String) map.get("iStatus"));
//                    String eventid = Actions.addEvent(context, (String) map.get("sRemindMSGText"), "", "",
//                            System.currentTimeMillis() + 1000 * 60 * 5,
//                            System.currentTimeMillis() + 1000 * 60 * 65, 3, (Integer) map.get("iCycleCategory"));
//                    Log.e("zhu", "eventid="+eventid);
//                    values.put(SalesSettings.RemindsColumns.EVENTID,
//                            eventid);
//                    context.getContentResolver().insert(SalesSettings.RemindsColumns.CONTENT_URI,
//                            values);
                }
            } catch (Exception e) {
                if (Actions.DEBUG) {
                    e.printStackTrace();
                }
                rlist = null;
            }
        }
        result = null;
        return rlist;
    }

    /**
     * 解析拜访任务结果数据
     * @param result 拜访任务结果数据
     * @param context 上下文
     */
    public static ArrayList<SyncTaskItem> parseMyTaskList(Object result, Context context) {
        if (Actions.DEBUG) {
            Log.e("zhu", "----------------------------parseMyTaskList=" + result);
        }
        ArrayList<SyncTaskItem> slist = null;
        if (result != null) {
            try {
            	slist = new ArrayList<SyncTaskItem>();
                Map<String, Object> map = (Map<String, Object>) result;
                String sid = (String) map.get("sEmployeeID");
                String dtid = (String) map.get("iDatingTaskID");
                Date date = (Date) map.get("dPlanningDate");
                String asid = (String) map.get("sAssignedEmployeeID");
                Log.e("zhu", "sEmployeeID=" + sid);
                Log.e("zhu", "iDatingTaskID=" + dtid);
                Log.e("zhu", "dPlanningDate=" +  date.toString());
                Log.e("zhu", "sAssignedEmployeeID=" + (String) map.get("sAssignedEmployeeID"));
                Object[] list = (Object[]) map.get("DatingTaskListItem");
                if (Actions.DEBUG) {
                    Log.e("zhu", "length=" + list.length);
                }
                for (int i = 0; i < list.length; i++) {
                    Map<String, Object> map2 = (Map<String, Object>) list[i];
                    SyncTaskItem item = new SyncTaskItem();
                    item.sEmployeeID = sid;
                    item.iDatingTaskID = dtid;
                    item.sAssignedEmployeeID = asid;
                    item.dPlanningDate = String.valueOf(date.getTime());
                    item.iItemNo = (String) map2.get("iItemNo");
                    item.sCustomerID = (String) map2.get("sCustomerID");
                    item.iVisitCategory = (Integer) map2.get("iVisitCategory");
                    slist.add(item);
                    if(Actions.DEBUG){
                    	Log.e("zhu", "=========================parseMyTaskList");
                        Log.e("zhu", "iItemNo=" + (String) map2.get("iItemNo"));
                        Log.e("zhu", "sCustomerID=" + (String) map2.get("sCustomerID"));
                        Log.e("zhu", "iVisitCategory=" + item.iVisitCategory);
                    }
                }
            } catch (Exception e) {
                if (Actions.DEBUG) {
                    e.printStackTrace();
                }
                slist = null;
            }
        }
        result = null;
        return slist;
    }

    /**
     * 解析产品结果数据
     * @param result 产品结果数据
     * @param context 上下文
     */
    public static ArrayList<SyncProductItem> parseProducts(Object result, Context context) {
        if (Actions.DEBUG) {
            Log.e("zhu", "---------------------------parseProducts=" + result);
        }
        ArrayList<SyncProductItem> pList = null;
        boolean isSuccess = false;
        if (result != null) {
            try {
            	pList = new ArrayList<SyncProductItem>();
                Map<String, Object> map = (Map<String, Object>) result;
            	Object[] list = (Object[])map.get("updateProducts"); 
            	if (Actions.DEBUG) {
                    Log.e("zhu", "updates length=" + list.length);
                }
                for (int i = 0; i < list.length; i++) {
                    Map<String, Object> map2 = (Map<String, Object>) list[i];
                    SyncProductItem item = new SyncProductItem();
                    item.sProductID = (String) map2.get("sProductID");
                    item.sProductCategoryID = (String) map2.get("sProductCategoryID");
                    item.sProductShortName = (String) map2.get("sProductShortName");
                    item.iSort = (Integer) map2.get("iSort");
                    item.mType = UPDATE;
                    pList.add(item);
                    if(Actions.DEBUG){
                    	 Log.e("zhu", "===============parseProducts");
                         Log.e("zhu", "sProductID=" + (String) map2.get("sProductID"));
                         Log.e("zhu", "sProductCategoryID=" + (String) map2.get("sProductCategoryID"));
                         Log.e("zhu", "sProductShortName=" + (String) map2.get("sProductShortName"));
                         //Log.e("zhu", "iStatus=" + (String) map2.get("iStatus"));
                    }
                    //ContentValues values = new ContentValues();
                    //values.put(SalesSettings.ProductsColumns.PRODUCTCATEGORY_ID, (String) map.get("sProductCategoryID"));
                    //values.put(SalesSettings.ProductsColumns.PRODUCT_ID, (String) map.get("sProductID"));
                    //values.put(SalesSettings.ProductsColumns.PRODUCT_NAME, (String) map.get("sProductShortName"));
                    //context.getContentResolver().insert(SalesSettings.ProductsColumns.CONTENT_URI_NO_NOTIFICATION, values);
                }

                Object[] deleteList = (Object[])map.get("deleteProducts"); 
                if (Actions.DEBUG) {
                    Log.e("zhu", "delete length=" + deleteList.length);
                }
                for (int i = 0; i < deleteList.length; i++) {
                    String pcid = (String) deleteList[i];
                    SyncProductItem item = new SyncProductItem();
                    item.sProductID = pcid;
                    item.mType = DELETE;
                    pList.add(item);
                    if (Actions.DEBUG) {
                    	Log.e("zhu", "delete pid=" + pcid);
                    }
                }
                isSuccess = true;
            } catch (Exception e) {
                if (Actions.DEBUG) {
                    e.printStackTrace();
                }
                pList = null;
            }
        }
        result = null;
        return pList;
    }

    /**
     * 解析货架信息数据
     * @param result 货架信息数据
     * @param context 上下文
     */
    public static ArrayList<CustomerShelfsItem> parseCustomerShelfs(Object result, Context context) {
        if (Actions.DEBUG) {
            Log.e("zhu", "--------------------------------parseCustomerShelfs=" + result);
        }
        ArrayList<CustomerShelfsItem> clist = null;
        if (result != null) {
        	Object[] array = (Object[])result;
        	Log.e("zhu","csize=" + array.length);
            try {
            	clist = new ArrayList<CustomerShelfsItem>();
            	for(int i = 0; i < array.length; i++){
            		Map<String, Object> map = (Map<String, Object>) array[i];
                    String customerId = (String) map.get("sCustomerID");
                    Log.e("zhu", "customerId=" + customerId);
                    Object[] list = (Object[]) map.get("ProductCategoryAndCustomerShelf");
                    if (Actions.DEBUG) {
                        Log.e("zhu", "length=" + list.length);
                    }
                    for (int j = 0; j < list.length; j++) {
                        Map<String, Object> map2 = (Map<String, Object>) list[j];
                        CustomerShelfsItem item = new CustomerShelfsItem();
                        item.customerId = customerId;
                        item.sProductCategoryID = ((String) map2.get("sProductCategoryID"));
                        item.iShelfArea = (String) map2.get("iShelfArea");//"9";//(String) map2.get("iShelfArea");
                        item.iShelfCount = (String) map2.get("iShelfCount");//"5";//(String) map2.get("iShelfCount");
                        item.iShelfLayer = (String) map2.get("iShelfLayer");//"7";//(String) map2.get("iShelfLayer");
                        clist.add(item);		
                        //ContentValues values = new ContentValues();
                        //values.put(SalesSettings.ProductShelfsColumns.CUSTOMER_ID, customerId);
                        //values.put(SalesSettings.ProductShelfsColumns.PRODUCTCATEGORY_ID, (String) map.get("sProductCategoryID"));
                        //values.put(SalesSettings.ProductShelfsColumns.PRODUCTSHELF_COUNT, (String) map.get("iShelfCount"));
                        //values.put(SalesSettings.ProductShelfsColumns.PRODUCTSHELF_AREA, (String) map.get("iShelfArea"));
                        //values.put(SalesSettings.ProductShelfsColumns.PRODUCTSHELF_LAYER, (String) map.get("iShelfLayer"));
                        //context.getContentResolver().insert(SalesSettings.ProductShelfsColumns.CONTENT_URI_NO_NOTIFICATION, values);
                        if(Actions.DEBUG){
                        	Log.e("zhu","map2="+map2);
                            Log.e("zhu", "===========================parseCustomerShelfs");
                            Log.e("zhu", "sProductCategoryID=" + (String) map2.get("sProductCategoryID"));
                            Log.e("zhu", "iShelfCount=" + (String) map2.get("iShelfCount"));
                            Log.e("zhu", "iShelfLayer=" + (String) map2.get("iShelfLayer"));
                            Log.e("zhu", "iShelfArea=" + (String) map2.get("iShelfArea"));
                            //Log.e("zhu", "iStatus=" + (String) map2.get("iStatus"));
                        }
                    }
            	}
            } catch (Exception e) {
                if (Actions.DEBUG) {
                    e.printStackTrace();
                }
                clist = null;
            }
        }
        return clist;
    }

    /**
     * 解析更新货架信息数据
     * @param result 货架信息数据
     * @param context 上下文
     */
    public static ArrayList<CustomerShelfsItem> parseUpdateCustomerPCs(Object result, Context context) {
        if (Actions.DEBUG) {
            Log.e("zhu", "--------------------------------parseUpdateCustomerPCs=" + result);
        }
        ArrayList<CustomerShelfsItem> clist = null;
        if (result != null) {
            Object[] array = (Object[])result;
            Log.e("zhu","csize=" + array.length);
            try {
                clist = new ArrayList<CustomerShelfsItem>();
                for(int i = 0; i < array.length; i++){
                    Map<String, Object> map = (Map<String, Object>) array[i];
                    String cid = (String) map.get("sCustomerID");

                    Object[] updatelist = (Object[]) map.get("updateProductCategory");
                    for(int ui = 0; ui < updatelist.length; ui++){
                        CustomerShelfsItem item = new CustomerShelfsItem();
                        item.customerId = cid;
                        item.sProductCategoryID = (String)updatelist[ui];
                        item.type = UPDATE;
                        clist.add(item);
                        if(Actions.DEBUG){
                            Log.e("zhu","update cid=" + cid +","+item.sProductCategoryID);
                        }
                    }
                    Object[] deletelist = (Object[]) map.get("deleteProductCategory");
                    for(int di = 0; di < deletelist.length; di++){
                        CustomerShelfsItem item = new CustomerShelfsItem();
                        item.customerId = cid;
                        item.sProductCategoryID = (String)deletelist[di];
                        item.type = DELETE;
                        Log.e("zhu","delete cid=" + cid +","+item.sProductCategoryID);
                        clist.add(item);
                    }
                }
            } catch (Exception e) {
                if (Actions.DEBUG) {
                    e.printStackTrace();
                }
                clist = null;
            }
        }
        return clist;
    }

    /**
     * 解析上传数据返回结果
     * @param result 上传数据返回结果
     */
    public static boolean parsePostData(Object result) {
    	if (Actions.DEBUG) {
            Log.e("zhu", "--------------------------------parsePostData=" + result);
        }
    	boolean isSuccedss = false;
    	if(result != null){
    		String status = (String)result;
    		if (Actions.DEBUG) {
                Log.e("zhu", "status" + status);
            }
    		if(status.equals("1")){
    			isSuccedss = true;
    		}
    	}
    	return isSuccedss;
    }

    /**
     * 解析网络时间
     * @param result 网络时间结果
     */
    public static long parseNetworkTime(Object result) {
        if (Actions.DEBUG) {
            Log.e("zhu", "--------------------------------parseNetworkTime=" + result);
        }
        long time = 0;

        if(result != null){
            Map<String, Object> map = (Map<String, Object>)  result;
                Date fromat = (Date) map.get("dNetworkTime");
                time = fromat.getTime();
        }
        if (Actions.DEBUG) {
            Log.e("zhu","parseNetworkTime = " + time);
        }
        return time;
    }
}
